<?php
include_once 'common/tools.php';
//启用一个带有ob_gzip压缩机的工作台
ob_start('ob_gzip');

$uId = @$_GET["uId"];

$config = require 'conf/config.ini.php';      //加载公用config.ini.php
$conn = mysql_connect($config["DB_HOST"], $config["DB_USER"], $config["DB_PWD"]);
mysql_select_db($config["DB_NAME"], $conn);
mysql_query("SET NAMES utf8");

$sql = "select m.msgId id, m.msgContent content, m.replayId rId, (select userId from live_user where userId = m.toUserId) toUserId, u.userId, u.userPic, u.userCity, u.userSex,". 
		"IF(u.userBirthDay <> '0000-00-00', (YEAR(CURDATE())-YEAR(u.userBirthDay))-(RIGHT(CURDATE(),5)<RIGHT(u.userBirthDay,5)), '0') userAge,".
		"m.updateDate ".
		"from live_message m, live_user u ".
		"where  ".
		"    u.id = m.fromUserId ".
		"and m.replayId = 0  ".
		"and m.delUserId <> '". $uId ."' ".
		"and (m.fromUserId = '". $uId ."' or m.toUserId = '". $uId ."' ) ".
		"order by m.updateDate desc";

$list = mysql_query($sql, $conn);
while ($obj = mysql_fetch_object($list)) {
	$objArray[] = $obj;
}
echo '{"sql":"' . $sql . '","results":' . json_encode($objArray) . '}';
//echo '{"results":' . json_encode($objArray) . '}';
//输出压缩成果
ob_end_flush();
?>